package com.geostart.constructionland.system.controller;

import com.geostar.constructionland.common.entity.analyse.AlyTypeMapping;
import com.geostar.constructionland.common.entity.response.ExtJsAjaxResponse;
import com.geostart.constructionland.system.service.AnalyseMappedFeignClient;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotBlank;

/**
 * @author chengan
 * @description 分析映射
 */
@Controller
@RequestMapping(path="/analyseMapped")
public class AnalyseMappedController {

    @Autowired
    AnalyseMappedFeignClient analyseMappedFeignClient;

    @RequestMapping(path = "/profile")
    public String initPage(){
        return "profile/analyseMapped_profile";
    }

    @PostMapping("/getAnalyseMapped")
    @ResponseBody
    @ApiOperation(value = "获取映射信息")
    public ExtJsAjaxResponse getAnalyseMapped(@NotBlank(message = "页码不能为空")  @RequestParam(value = "page") int pageNo,
                                                @NotBlank(message = "每页数量不能为空") @RequestParam(value = "limit") int pageNum,
                                              String query_mapped_name){
        return analyseMappedFeignClient.getAnalyseMapped(pageNo,pageNum,query_mapped_name);
    }

    @PostMapping("/insertAnalyseMapped")
    @ResponseBody
    @ApiOperation(value = "新增映射信息")
    public ExtJsAjaxResponse updateAnalyseMapped(AlyTypeMapping alyTypeMapping){
        return analyseMappedFeignClient.addAnalyseMapped(alyTypeMapping);
    }
    @ApiOperation(value = "删除映射信息")
    @ResponseBody
    @PostMapping("/deleteAnalyseMapped")
    public ExtJsAjaxResponse deleteAnalyseMapped(@RequestParam(value = "mappingId") String mappingId){
        return analyseMappedFeignClient.deleteAnalyseMapped(mappingId);
    }


    @ApiOperation(value = "更新映射信息")
    @ResponseBody
    @PostMapping("/updateAnalyseMapped")
    public ExtJsAjaxResponse insertAnalyseMapped(AlyTypeMapping alyTypeMapping){
        return analyseMappedFeignClient.updateAnalyseMapped(alyTypeMapping);
    }
}
